<%@ page 	language="java" 
			contentType="text/html; charset=utf-8"
			pageEncoding="utf-8"
			import="view.AdminContent" 
			import="java.net.URL"
			%>

<% AdminContent thispage = new AdminContent("client"); 
	String tabName 	= "";
	
	try {
		tabName = request.getParameter("name");
		
		if (tabName.equals(null)) {
			tabName = "orderVisit";
		}
	}
	catch (NullPointerException ex) {
		tabName = "orderVisit";
	}
%>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title><% out.print(thispage.getTitle()); %></title>


<script src="js/jquery-1.10.2.min.js"></script>

<script  type="text/javascript">
function call(name){
		window.location.replace("client.jsp?name="+name);
		
	}
</script>

<link rel="stylesheet" type="text/css" href="css/fonts.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
<link rel="stylesheet" type="text/css" href="css/page.css">
<link rel="stylesheet" type="text/css" href="css/admin.css">

</head>

<body>
	<header>
		<section id="topBar">
			<div class="center">
				<div id="logo">
					<div>
						SO<b>P</b>H
					</div>
					<div>
						System obsługi <br />przedstawicieli handlowych
					</div>
				</div>
				<div>
					<p>You are logged as ()</p>
					<p>Log out</p>
				</div>
			</div>
		</section>

		<section id="slideshow">
			<% 				
					for (String[] imageName : thispage.getHeader().getSlideshow()) {
						
						String imageURL = imageName[0];
						String imageTitle = imageName[1];
						String imageDesc = imageName[2];
						
						out.print("<img src=\"images/slideshow/" + imageURL + "\" alt=\"\" />" +
									"<div id=\"caption\">" +
										"<h2>" + imageTitle + "</h2>" +
										"<h3>" + imageDesc + "</h3>" +
									"</div>");
					}
			%>
		</section>
	</header>

	<section id="infoBar">
		<div class="center">
			<h2></h2>
			<h3></h3>
		</div>
	</section>
	
	<section id="content" class="center admin">	
		<nav>
			<ul>
			<% 
				for (String[] item : thispage.getHeader().getMenu().getMenuList()) {
					
					String fullName = item[0];
					String shortName = item[1];
					String desc = item[2];
					
					if (shortName.equals(tabName))
						out.print("<li class=\"users active\" alt=\"" + desc + "\" onclick='call(\"" + shortName + "\")'>" + fullName + "</li>");
					else
						out.print("<li class=\"users\" alt=\"" + desc + "\" onclick='call(\"" + shortName + "\")'>" + fullName + "</li>");
				}
			%>
			</ul>
		</nav>
		<article>
			<% 
				out.print(thispage.getContent().loadTab(tabName));
			%>
		</article>
	</section>
	
	
	<footer class="center">
		<div><% out.print(thispage.getFooter().getAllRightsReservedText()); %></div>
		<div>
			<ul><% 				
				for (String pageName[]:thispage.getFooter().getMenu().getMenuList()) {								
					out.print("<li><a href=\"" + thispage.normalizeURL(pageName[0]) + "\">" + pageName[0] + "</a></li>"  );								
				}
			 %>
			 </ul>
		</div>
	</footer>
	
	<script  type="text/javascript">
	
		$( document ).ready(function() {

			// changing tabs
			$( "li.users" ).on( "click", function( event ) {
				$("li.active").removeClass("active");
				$(this).addClass("active");
			});

			
			// change the title 
			var title = $("#content > nav > ul > li.active").html();
			$("#infoBar > .center > h2").append(title);
			
			// change the description
			var desc = $("#content > nav > ul > li.active").attr("alt");
			$("#infoBar > .center > h3").append(desc);
		});
	</script>
	
</body>
</html>